//
//  LHRecommendHomePageViewController.m
//  Knight_Tour
//
//  Created by Bruce_Lin on 15/5/13.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendHomePageViewController.h"
#import "LHRecommendHomePageView.h"
#import "LHRecommendCityViewController.h"
#import "MyNavgationView.h"
#import "LHRecommendTourNotesViewController.h"
#import "LHRecommendHomePageScrollView.h"
#import "LHRecommendHomePageCollectionView.h"
#import "LHRecommendTourNotesDetailViewController.h"
#import "LHRecommendTravelNotesModel.h"
#import "LHNetworkHandle.h"



@interface LHRecommendHomePageViewController ()<jumpToNotesDetailDelegate>

@property (nonatomic, retain) NSMutableArray *notesArr_str;

@end

@implementation LHRecommendHomePageViewController


- (void)dealloc
{
    [_notesArr_str release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createRecommedTourHomePage];
    
    self.view.backgroundColor = [UIColor colorWithRed:0.871 green:0.962 blue:0.965 alpha:1.000];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBarHidden = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self createNavigation];
    
    
}


// 创建自定义导航栏
- (void)createNavigation
{
    MyNavgationView *myNaView = [[MyNavgationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    
    [myNaView creatTitle:@"推荐游"];
    
    [self.view addSubview:myNaView];
    
    [myNaView release];
    
}



/**
 *  创建推荐游主页
 */
- (void)createRecommedTourHomePage
{
    
    // 创建scrollView
    UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    
//    myScrollView.backgroundColor = [UIColor colorWithRed:0.915 green:0.606 blue:0.052 alpha:1.000];
    
    myScrollView.contentSize = CGSizeMake(0, [UIScreen mainScreen].bounds.size.height / 3 + ([UIScreen mainScreen].bounds.size.width - 30) / 2 * 3 + 30  + [UIScreen mainScreen].bounds.size.height / 5  + 64 + 60);
    
    myScrollView.showsHorizontalScrollIndicator = YES;
    
    [self.view addSubview:myScrollView];
    
    [myScrollView release];
    
    
    // 创建首页轮播图
    LHRecommendHomePageScrollView *homePageScro = [[LHRecommendHomePageScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, [UIScreen mainScreen].bounds.size.height / 3)];
    
    [myScrollView addSubview:homePageScro];
    
    [homePageScro release];
    
    // 创建四个标签视图
    LHRecommendHomePageView *homePageView = [[LHRecommendHomePageView alloc] initWithFrame:CGRectMake(0, homePageScro.frame.origin.y + homePageScro.frame.size.height, self.view.frame.size.width, [UIScreen mainScreen].bounds.size.height / 5 )];
        
    [homePageView.CityButton addTarget:self action:@selector(pushCity) forControlEvents:UIControlEventTouchUpInside];
    
    [homePageView.TourButton addTarget:self action:@selector(pushTourNote) forControlEvents:UIControlEventTouchUpInside];
    
    
    [myScrollView addSubview:homePageView];
    
    [homePageView release];
    
    // 创建首页collectionView
    LHRecommendHomePageCollectionView *collectionView = [[LHRecommendHomePageCollectionView alloc] initWithFrame:CGRectMake(0, homePageView.frame.origin.y + homePageView.frame.size.height + 10, self.view.frame.size.width, ([UIScreen mainScreen].bounds.size.width - 30) / 2 * 3 + 30 )];
    
    collectionView.delegate = self;
    
    [myScrollView addSubview:collectionView];
    
    [collectionView release];
    
}
// 实现跳转到游记详情页面协议方法
- (void)jumpToNotesDetailViewWithIndexPath:(NSIndexPath *)indexPath notesArr:(NSMutableArray *)notesArr
{
    LHRecommendTourNotesDetailViewController *noteView = [[[LHRecommendTourNotesDetailViewController alloc] init] autorelease];
    
    noteView.notesDetail_id = [notesArr[indexPath.row] notesId];
    
    noteView.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:noteView animated:YES];
    
}

/**
 *  推荐城市点击事件
 */
- (void)pushCity
{
    LHRecommendCityViewController *cityVC = [[[LHRecommendCityViewController alloc] init] autorelease];
    
    cityVC.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:cityVC animated:YES];
    
}

/**
 *  推荐游记点击方法
 */
- (void)pushTourNote
{
    LHRecommendTourNotesViewController *noteVC = [[[LHRecommendTourNotesViewController alloc] init] autorelease];
    
    noteVC.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:noteVC animated:YES];
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
